package com.mingrisoft;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;

import com.mingrisoft.database.device;
import com.mingrisoft.database.grid2adapter;
import com.mingrisoft.database.gridadapter;


public class menuActivity extends Activity {
    private GridView gd, gd2;
    private device dev1 = new device(R.drawable.settingcontrol, "设备控制");
    private device dev2 = new device(R.drawable.setting, "阈值设置");
    private device dev3 = new device(R.drawable.fastlearn, "快速入门");
    private device dev4 = new device(R.drawable.mine, "关于我们");
    private device[] devs = {dev1, dev2, dev3, dev4};
    private device dev5 = new device(R.drawable.datawatch, "数据监测");
    private device dev6 = new device(R.drawable.tendencechange, "变化趋势");
    private device dev7 = new device(R.drawable.workers, "值班人员");
    private device dev8 = new device(R.drawable.calaturemanage, "植物百科");
    private device[] devs2 = {dev5, dev6, dev7, dev8};
    private  Intent intent = new Intent();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_menu);
        initView();
        initData();
        gd.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                switch (position) {
                    case 0:
                        intent.setClass(menuActivity.this, deviceControlActivity.class);
                        startActivity(intent);
                        break;
                    case 1:
                        intent.setClass(menuActivity.this, limitSettingActivity.class);
                        startActivity(intent);
                        break;
                    case 2:
                        break;
                    case 3:
                        break;
                    case 4:
                        break;
                    default:
                        return;
                }

//                menuActivity.this.finish();
            }
        });
        gd2.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Log.d("debug","position:"+position+"id:"+id);
                switch (position) {
                    case 0:
                        Log.d("debug","dataWatchActivity222222222222222222222222222222\n");
                        intent.setClass(menuActivity.this, dataWatchActivity.class);
                        startActivity(intent);
                        break;
                    case 1:
                        Log.d("debug","drawRealTimeMapActivity1111111111111111111111111111111111111111111111111111\n");
                        intent.setClass(menuActivity.this, drawRealTimeMapActivity.class);
                        startActivity(intent);
                        break;
                    case 2:
                        break;
                    case 3:
                        break;
                    case 4:
                        break;
                    default:
                        Log.d("debug","no function");
                        break;
                }

            }
        });
    }

    private void initView() {
        // TODO Auto-generated method stub
        gd = (GridView) findViewById(R.id.grid);
        gd2 = (GridView) findViewById(R.id.grid2);
    }

    private void initData() {
        // TODO Auto-generated method stub
        gd.setAdapter(new gridadapter(devs, this));
        gd2.setAdapter(new grid2adapter(devs2, this));
    }
}
